package entity;

import com.github.javaparser.ast.expr.MethodCallExpr;
import com.thoughtworks.qdox.model.JavaClass;
import type.AccessModifierEnum;

import java.util.List;

/**
 * 可调用实体（方法、构造器）
 *
 * @author Tao Lu
 */
public abstract class CallableEntity extends BaseEntity {
    private AccessModifierEnum accessModifierEnum;

    private JavaClass declarationClass;  // 从属的类
    private List<VariableEntity> arguments; // 方法参数
    private List<MethodCallExpr> calledMethods;   // 调用的方法列表（不含构造器）

    public AccessModifierEnum getAccessModifierEnum() {
        return accessModifierEnum;
    }

    public void setAccessModifierEnum(AccessModifierEnum accessModifierEnum) {
        this.accessModifierEnum = accessModifierEnum;
    }

    public JavaClass getDeclarationClass() {
        return declarationClass;
    }

    public void setDeclarationClass(JavaClass declarationClass) {
        this.declarationClass = declarationClass;
    }

    public List<VariableEntity> getArguments() {
        return arguments;
    }

    public void setArguments(List<VariableEntity> arguments) {
        this.arguments = arguments;
    }

    public List<MethodCallExpr> getCalledMethods() {
        return calledMethods;
    }

    public void setCalledMethods(List<MethodCallExpr> calledMethods) {
        this.calledMethods = calledMethods;
    }

    @Override
    public String toString() {
        return "CallableEntity{\n\t" + super.toString() +
                "\n\t\"accessModifierEnum\":" +
                accessModifierEnum +
                ",\n\t\"declarationClass\":" +
                declarationClass +
                ",\n\t\"arguments\":" +
                arguments +
                ",\n\t\"calledMethods\":" +
                calledMethods +
                "\n}";
    }
}
